{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f6af939e-e693-4f1f-aa0a-4906b7fd3932",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import boto3\n",
    "import json\n",
    "import os\n",
    "import numpy as np\n",
    "\n",
    "smr_client = boto3.client(\"sagemaker-runtime\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fb87fb8e-9032-4a39-a171-c676766ba3ca",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "def get_vector_by_sm_endpoint(questions, sm_client, endpoint_name, instruction=''):\n",
    "    parameters = {\n",
    "    }\n",
    "\n",
    "    response_model = sm_client.invoke_endpoint(\n",
    "        EndpointName=endpoint_name,\n",
    "        Body=json.dumps(\n",
    "            {\n",
    "                \"inputs\": questions,\n",
    "                \"is_query\": True,\n",
    "                \"instruction\" :  instruction,\n",
    "                \"parameters\" : \"\"\n",
    "            }\n",
    "        ),\n",
    "        ContentType=\"application/json\",\n",
    "    )\n",
    "    # 中文instruction => 为这个句子生成表示以用于检索相关文章：\n",
    "    # English instruction => Represent this sentence for searching relevant passages:\n",
    "    json_str = response_model['Body'].read().decode('utf8')\n",
    "    json_obj = json.loads(json_str)\n",
    "    embeddings = json_obj['sentence_embeddings']\n",
    "    return embeddings[0]\n",
    "\n",
    "def similarity_calc(vec1, vec2):\n",
    "    dot_product = np.dot(vec1, vec2)\n",
    "    norm_vec1 = np.sqrt(np.dot(vec1, vec1))\n",
    "    norm_vec2 = np.sqrt(np.dot(vec2, vec2))\n",
    "    cosine_sim = dot_product / (norm_vec1 * norm_vec2)\n",
    "    \n",
    "    return cosine_sim\n",
    "\n",
    "def similarity_calc_stat(vec1, vec2_list):\n",
    "    sim_list = [ similarity_calc(vec1, vec2) for vec2 in vec2_list ]\n",
    "    return np.max(sim_list), np.mean(sim_list)\n",
    "\n",
    "def similarity_stat(vec1, vec2_list, pos_sim_val):\n",
    "    sim_list = [ similarity_calc(vec1, vec2) for vec2 in vec2_list ]\n",
    "    wrong_cnt = 0\n",
    "    delta_sim_val_list = []\n",
    "    \n",
    "    for item in sim_list:\n",
    "        if item > pos_sim_val:\n",
    "            wrong_cnt += 1\n",
    "    \n",
    "    return wrong_cnt, sim_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "5b238f0b-48c2-4e63-91a0-d9a23ef11649",
   "metadata": {},
   "outputs": [],
   "source": [
    "def visual_preprocess(input_file, pair_a_name, pair_b_name, neg_name, endpoint_name, instruction=''):           \n",
    "    pos_rank_list = []\n",
    "    neg_similarity_list = []\n",
    "    pos_similarity_list = []\n",
    "    test_items = []\n",
    "    \n",
    "    filename = os.path.basename(input_file).split('.')[0]\n",
    "    with open(input_file, 'r') as input_f:\n",
    "        lines = input_f.readlines()\n",
    "        for line in lines:\n",
    "            json_obj = json.loads(line)\n",
    "            test_items.append(json_obj)\n",
    "\n",
    "        for idx, test_item in enumerate(test_items):\n",
    "            q = test_item['query']\n",
    "            p = test_item['pos'][0]\n",
    "            neg_p_list = list(set(test_item['neg']))\n",
    "            q_emb = get_vector_by_sm_endpoint(q, smr_client, endpoint_name, instruction)\n",
    "            p_emb = get_vector_by_sm_endpoint(p, smr_client, endpoint_name)\n",
    "            neg_p_embs = [ get_vector_by_sm_endpoint(neg_p, smr_client, endpoint_name) for neg_p in neg_p_list ]\n",
    "\n",
    "            pos_sim = similarity_calc(q_emb, p_emb)\n",
    "            pos_rank, neg_sim_vals = similarity_stat(q_emb, neg_p_embs, pos_sim)\n",
    "            \n",
    "            pos_similarity_list.append(pos_sim)\n",
    "            pos_rank_list.append(pos_rank)\n",
    "            neg_similarity_list.extend(neg_sim_vals)\n",
    "\n",
    "            if idx % 100 == 0:\n",
    "                print(f\"{idx}-th : pos_sim: {pos_sim}, pos_rank:{pos_rank}\")\n",
    "              \n",
    "    return pos_rank_list, pos_similarity_list, neg_similarity_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "50421ffe-3a1f-49db-90a7-640a13a69b4d",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "from collections import Counter\n",
    "import random\n",
    "\n",
    "def plot_stat(pos_rank_list, pos_similarity_list, neg_similarity_list, plot_name):\n",
    "    def gen_label_name(k):\n",
    "        return \"other\" if k > 4 else f\"Top{k+1}\" \n",
    "    pos_rank_str_list = [ gen_label_name(item) for item in pos_rank_list]\n",
    "    counter = Counter(pos_rank_str_list)\n",
    "    \n",
    "    result_dict = { k : v for k, v in counter.items()}\n",
    "    \n",
    "    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))\n",
    "    \n",
    "    plt.figure(figsize=(6, 6))\n",
    "    sns.set_style(\"whitegrid\")\n",
    "    ax1.pie(result_dict.values(), labels=result_dict.keys(), autopct='%1.1f%%', startangle=140, labeldistance=1.1)\n",
    "    ax1.set_title('PostiveLabel Rank')  \n",
    "\n",
    "    plt.figure(figsize=(8, 6))\n",
    "    sns.set_style(\"whitegrid\")\n",
    "    N = len(pos_similarity_list)\n",
    "    sample_neg_similarity_list = random.sample(neg_similarity_list, N)\n",
    "    sns.histplot(pos_similarity_list, color='green',kde=True, ax=ax2)\n",
    "    sns.histplot(sample_neg_similarity_list, color='red',kde=True, ax=ax2)\n",
    "    ax2.set_title('Similarity Dist')\n",
    "    ax2.set_xlabel('Sim_Value')\n",
    "    ax2.set_ylabel('Frequency')\n",
    "    \n",
    "    plt.tight_layout()\n",
    "    fig.savefig(f\"{plot_name}.png\", dpi=100, bbox_inches='tight')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95119b3c-6666-46ac-91a4-165e44bb07ef",
   "metadata": {},
   "source": [
    "### Check Recall@N and similarity distribution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "ccb62474-5dd6-4673-9ccb-c479df1062e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "endpoint_name_bge = 'bge-large-zh-2023-09-15-08-29-52-242-endpoint'\n",
    "endpoint_name_st = 'finetuned-mpnet-2023-09-16-06-05-37-797-endpoint'\n",
    "endpoint_name_bge15 = 'bge-zh-15-2023-09-17-01-00-27-086-endpoint'\n",
    "endpoint_name_st_ft = 'finetuned-mpnet-bz9-2023-09-17-23-26-37-824-endpoint'\n",
    "endpoint_name_bge15_ft = 'bge15-finetuned-2023-09-18-02-41-16-015-endpoint'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "a7761887-d2f2-45d1-bc05-094e1e5fdf69",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "!mkdir bge_finetune15\n",
    "!mkdir bge_finetune15/eval\n",
    "!mkdir bge_finetune15/test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fef9a45c-6481-413a-8a2c-2cc8629b9b16",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "%time\n",
    "pos_rank_list, pos_similarity_list, neg_similarity_list = visual_preprocess('chatgpt_synthesis/qq1_valid.jsonl', 'origin_q', 'generated_q','generated_neg',endpoint_name_bge15_ft)\n",
    "plot_stat(pos_rank_list, pos_similarity_list, neg_similarity_list, 'bge_finetune15/eval/origin_q-generated_q-generated_neg-bge')\n",
    "\n",
    "pos_rank_list, pos_similarity_list, neg_similarity_list = visual_preprocess('chatgpt_synthesis/qq2_valid.jsonl', 'origin_q', 'generated_q', 'origin_neg',endpoint_name_bge15_ft)\n",
    "plot_stat(pos_rank_list, pos_similarity_list, neg_similarity_list, 'bge_finetune15/eval/origin_q-generated_q-origin_neg-bge')\n",
    "\n",
    "pos_rank_list, pos_similarity_list, neg_similarity_list = visual_preprocess('chatgpt_synthesis/oqgd_valid.jsonl', 'origin_q', 'generated_d', 'generated_d',endpoint_name_bge15_ft)\n",
    "plot_stat(pos_rank_list, pos_similarity_list, neg_similarity_list, 'bge_finetune15/eval/origin_q-generated_d-generated_d-bge')\n",
    "\n",
    "pos_rank_list, pos_similarity_list, neg_similarity_list = visual_preprocess('chatgpt_synthesis/gqod_valid.jsonl', 'generated_q', 'origin_d', 'origin_d',endpoint_name_bge15_ft)\n",
    "plot_stat(pos_rank_list, pos_similarity_list, neg_similarity_list, 'bge_finetune15/eval/generated_q-origin_d-origin_d-bge')\n",
    "\n",
    "pos_rank_list, pos_similarity_list, neg_similarity_list = visual_preprocess('chatgpt_synthesis/qq1_test.jsonl', 'origin_q', 'generated_q','generated_neg',endpoint_name_bge15_ft)\n",
    "plot_stat(pos_rank_list, pos_similarity_list, neg_similarity_list, 'bge_finetune15/test/origin_q-generated_q-generated_neg-bge')\n",
    "\n",
    "pos_rank_list, pos_similarity_list, neg_similarity_list = visual_preprocess('chatgpt_synthesis/qq2_test.jsonl', 'origin_q', 'generated_q', 'origin_neg',endpoint_name_bge15_ft)\n",
    "plot_stat(pos_rank_list, pos_similarity_list, neg_similarity_list, 'bge_finetune15/test/origin_q-generated_q-origin_neg-bge')\n",
    "\n",
    "pos_rank_list, pos_similarity_list, neg_similarity_list = visual_preprocess('chatgpt_synthesis/oqgd_test.jsonl', 'origin_q', 'generated_d', 'generated_d',endpoint_name_bge15_ft)\n",
    "plot_stat(pos_rank_list, pos_similarity_list, neg_similarity_list, 'bge_finetune15/test/origin_q-generated_d-generated_d-bge')\n",
    "\n",
    "pos_rank_list, pos_similarity_list, neg_similarity_list = visual_preprocess('chatgpt_synthesis/gqod_test.jsonl', 'generated_q', 'origin_d', 'origin_d',endpoint_name_bge15_ft)\n",
    "plot_stat(pos_rank_list, pos_similarity_list, neg_similarity_list, 'bge_finetune15/test/generated_q-origin_d-origin_d-bge')"
   ]
  }
 ],
 "metadata": {
  "availableInstances": [
   {
    "_defaultOrder": 0,
    "_isFastLaunch": true,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 4,
    "name": "ml.t3.medium",
    "vcpuNum": 2
   },
   {
    "_defaultOrder": 1,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 8,
    "name": "ml.t3.large",
    "vcpuNum": 2
   },
   {
    "_defaultOrder": 2,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 16,
    "name": "ml.t3.xlarge",
    "vcpuNum": 4
   },
   {
    "_defaultOrder": 3,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 32,
    "name": "ml.t3.2xlarge",
    "vcpuNum": 8
   },
   {
    "_defaultOrder": 4,
    "_isFastLaunch": true,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 8,
    "name": "ml.m5.large",
    "vcpuNum": 2
   },
   {
    "_defaultOrder": 5,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 16,
    "name": "ml.m5.xlarge",
    "vcpuNum": 4
   },
   {
    "_defaultOrder": 6,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 32,
    "name": "ml.m5.2xlarge",
    "vcpuNum": 8
   },
   {
    "_defaultOrder": 7,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 64,
    "name": "ml.m5.4xlarge",
    "vcpuNum": 16
   },
   {
    "_defaultOrder": 8,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 128,
    "name": "ml.m5.8xlarge",
    "vcpuNum": 32
   },
   {
    "_defaultOrder": 9,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 192,
    "name": "ml.m5.12xlarge",
    "vcpuNum": 48
   },
   {
    "_defaultOrder": 10,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 256,
    "name": "ml.m5.16xlarge",
    "vcpuNum": 64
   },
   {
    "_defaultOrder": 11,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 384,
    "name": "ml.m5.24xlarge",
    "vcpuNum": 96
   },
   {
    "_defaultOrder": 12,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 8,
    "name": "ml.m5d.large",
    "vcpuNum": 2
   },
   {
    "_defaultOrder": 13,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 16,
    "name": "ml.m5d.xlarge",
    "vcpuNum": 4
   },
   {
    "_defaultOrder": 14,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 32,
    "name": "ml.m5d.2xlarge",
    "vcpuNum": 8
   },
   {
    "_defaultOrder": 15,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 64,
    "name": "ml.m5d.4xlarge",
    "vcpuNum": 16
   },
   {
    "_defaultOrder": 16,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 128,
    "name": "ml.m5d.8xlarge",
    "vcpuNum": 32
   },
   {
    "_defaultOrder": 17,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 192,
    "name": "ml.m5d.12xlarge",
    "vcpuNum": 48
   },
   {
    "_defaultOrder": 18,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 256,
    "name": "ml.m5d.16xlarge",
    "vcpuNum": 64
   },
   {
    "_defaultOrder": 19,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 384,
    "name": "ml.m5d.24xlarge",
    "vcpuNum": 96
   },
   {
    "_defaultOrder": 20,
    "_isFastLaunch": false,
    "category": "General purpose",
    "gpuNum": 0,
    "hideHardwareSpecs": true,
    "memoryGiB": 0,
    "name": "ml.geospatial.interactive",
    "supportedImageNames": [
     "sagemaker-geospatial-v1-0"
    ],
    "vcpuNum": 0
   },
   {
    "_defaultOrder": 21,
    "_isFastLaunch": true,
    "category": "Compute optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 4,
    "name": "ml.c5.large",
    "vcpuNum": 2
   },
   {
    "_defaultOrder": 22,
    "_isFastLaunch": false,
    "category": "Compute optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 8,
    "name": "ml.c5.xlarge",
    "vcpuNum": 4
   },
   {
    "_defaultOrder": 23,
    "_isFastLaunch": false,
    "category": "Compute optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 16,
    "name": "ml.c5.2xlarge",
    "vcpuNum": 8
   },
   {
    "_defaultOrder": 24,
    "_isFastLaunch": false,
    "category": "Compute optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 32,
    "name": "ml.c5.4xlarge",
    "vcpuNum": 16
   },
   {
    "_defaultOrder": 25,
    "_isFastLaunch": false,
    "category": "Compute optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 72,
    "name": "ml.c5.9xlarge",
    "vcpuNum": 36
   },
   {
    "_defaultOrder": 26,
    "_isFastLaunch": false,
    "category": "Compute optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 96,
    "name": "ml.c5.12xlarge",
    "vcpuNum": 48
   },
   {
    "_defaultOrder": 27,
    "_isFastLaunch": false,
    "category": "Compute optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 144,
    "name": "ml.c5.18xlarge",
    "vcpuNum": 72
   },
   {
    "_defaultOrder": 28,
    "_isFastLaunch": false,
    "category": "Compute optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 192,
    "name": "ml.c5.24xlarge",
    "vcpuNum": 96
   },
   {
    "_defaultOrder": 29,
    "_isFastLaunch": true,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 16,
    "name": "ml.g4dn.xlarge",
    "vcpuNum": 4
   },
   {
    "_defaultOrder": 30,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 32,
    "name": "ml.g4dn.2xlarge",
    "vcpuNum": 8
   },
   {
    "_defaultOrder": 31,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 64,
    "name": "ml.g4dn.4xlarge",
    "vcpuNum": 16
   },
   {
    "_defaultOrder": 32,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 128,
    "name": "ml.g4dn.8xlarge",
    "vcpuNum": 32
   },
   {
    "_defaultOrder": 33,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 4,
    "hideHardwareSpecs": false,
    "memoryGiB": 192,
    "name": "ml.g4dn.12xlarge",
    "vcpuNum": 48
   },
   {
    "_defaultOrder": 34,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 256,
    "name": "ml.g4dn.16xlarge",
    "vcpuNum": 64
   },
   {
    "_defaultOrder": 35,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 61,
    "name": "ml.p3.2xlarge",
    "vcpuNum": 8
   },
   {
    "_defaultOrder": 36,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 4,
    "hideHardwareSpecs": false,
    "memoryGiB": 244,
    "name": "ml.p3.8xlarge",
    "vcpuNum": 32
   },
   {
    "_defaultOrder": 37,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 8,
    "hideHardwareSpecs": false,
    "memoryGiB": 488,
    "name": "ml.p3.16xlarge",
    "vcpuNum": 64
   },
   {
    "_defaultOrder": 38,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 8,
    "hideHardwareSpecs": false,
    "memoryGiB": 768,
    "name": "ml.p3dn.24xlarge",
    "vcpuNum": 96
   },
   {
    "_defaultOrder": 39,
    "_isFastLaunch": false,
    "category": "Memory Optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 16,
    "name": "ml.r5.large",
    "vcpuNum": 2
   },
   {
    "_defaultOrder": 40,
    "_isFastLaunch": false,
    "category": "Memory Optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 32,
    "name": "ml.r5.xlarge",
    "vcpuNum": 4
   },
   {
    "_defaultOrder": 41,
    "_isFastLaunch": false,
    "category": "Memory Optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 64,
    "name": "ml.r5.2xlarge",
    "vcpuNum": 8
   },
   {
    "_defaultOrder": 42,
    "_isFastLaunch": false,
    "category": "Memory Optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 128,
    "name": "ml.r5.4xlarge",
    "vcpuNum": 16
   },
   {
    "_defaultOrder": 43,
    "_isFastLaunch": false,
    "category": "Memory Optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 256,
    "name": "ml.r5.8xlarge",
    "vcpuNum": 32
   },
   {
    "_defaultOrder": 44,
    "_isFastLaunch": false,
    "category": "Memory Optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 384,
    "name": "ml.r5.12xlarge",
    "vcpuNum": 48
   },
   {
    "_defaultOrder": 45,
    "_isFastLaunch": false,
    "category": "Memory Optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 512,
    "name": "ml.r5.16xlarge",
    "vcpuNum": 64
   },
   {
    "_defaultOrder": 46,
    "_isFastLaunch": false,
    "category": "Memory Optimized",
    "gpuNum": 0,
    "hideHardwareSpecs": false,
    "memoryGiB": 768,
    "name": "ml.r5.24xlarge",
    "vcpuNum": 96
   },
   {
    "_defaultOrder": 47,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 16,
    "name": "ml.g5.xlarge",
    "vcpuNum": 4
   },
   {
    "_defaultOrder": 48,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 32,
    "name": "ml.g5.2xlarge",
    "vcpuNum": 8
   },
   {
    "_defaultOrder": 49,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 64,
    "name": "ml.g5.4xlarge",
    "vcpuNum": 16
   },
   {
    "_defaultOrder": 50,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 128,
    "name": "ml.g5.8xlarge",
    "vcpuNum": 32
   },
   {
    "_defaultOrder": 51,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 1,
    "hideHardwareSpecs": false,
    "memoryGiB": 256,
    "name": "ml.g5.16xlarge",
    "vcpuNum": 64
   },
   {
    "_defaultOrder": 52,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 4,
    "hideHardwareSpecs": false,
    "memoryGiB": 192,
    "name": "ml.g5.12xlarge",
    "vcpuNum": 48
   },
   {
    "_defaultOrder": 53,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 4,
    "hideHardwareSpecs": false,
    "memoryGiB": 384,
    "name": "ml.g5.24xlarge",
    "vcpuNum": 96
   },
   {
    "_defaultOrder": 54,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 8,
    "hideHardwareSpecs": false,
    "memoryGiB": 768,
    "name": "ml.g5.48xlarge",
    "vcpuNum": 192
   },
   {
    "_defaultOrder": 55,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 8,
    "hideHardwareSpecs": false,
    "memoryGiB": 1152,
    "name": "ml.p4d.24xlarge",
    "vcpuNum": 96
   },
   {
    "_defaultOrder": 56,
    "_isFastLaunch": false,
    "category": "Accelerated computing",
    "gpuNum": 8,
    "hideHardwareSpecs": false,
    "memoryGiB": 1152,
    "name": "ml.p4de.24xlarge",
    "vcpuNum": 96
   }
  ],
  "instance_type": "ml.m5.large",
  "kernelspec": {
   "display_name": "Python 3 (Data Science 3.0)",
   "language": "python",
   "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/sagemaker-data-science-310-v1"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
